import request, { get } from '@/utils/request'

// 获取商家首页概览数据
export function getMerchantOverview() {
  return request({
    url: '/dashboard/overview',
    method: 'get'
  })
}

// 获取商家首页交易数据
export function getMerchantTransaction() {
  return request({
    url: '/dashboard/transaction',
    method: 'get'
  })
}

// 获取商家首页商品数据
export function getMerchantGoods() {
  return request({
    url: '/dashboard/goods',
    method: 'get'
  })
}

// 获取商家首页订单数据
export function getMerchantOrders() {
  return request({
    url: '/dashboard/orders',
    method: 'get'
  })
}

// 获取商家首页售后数据
export function getMerchantAfterSales() {
  return request({
    url: '/dashboard/after-sales',
    method: 'get'
  })
}

// 获取商家首页违规数据
export function getMerchantViolations() {
  return request({
    url: '/dashboard/violations',
    method: 'get'
  })
}

// 获取商家首页销售趋势数据
export function getMerchantSalesTrend(params) {
  return request({
    url: '/dashboard/sales-trend',
    method: 'get',
    params
  })
}

// 获取商家首页商品分类销售数据
export function getMerchantCategorySales() {
  return request({
    url: '/dashboard/category-sales',
    method: 'get'
  })
}

// 获取商家首页热销商品数据
export function getMerchantHotGoods(params) {
  return request({
    url: '/dashboard/hot-goods',
    method: 'get',
    params
  })
}

// 获取商家首页待处理事项
export function getMerchantPendingTasks() {
  return request({
    url: '/dashboard/pending-tasks',
    method: 'get'
  })
}

// 获取实时统计数据
export function getRealTimeStats() {
  return request({
    url: '/dashboard/realtime-stats',
    method: 'get'
  })
}

// 获取收入统计
export function getRevenueStats(params) {
  return request({
    url: '/dashboard/revenue-stats',
    method: 'get',
    params
  })
}

// 获取客户统计
export function getCustomerStats(params) {
  return request({
    url: '/dashboard/customer-stats',
    method: 'get',
    params
  })
}

// 获取营业状态
export function getBusinessStatus() {
  return get('/dashboard/business-status')
}

// 获取服务区域统计
export function getServiceAreaStats() {
  return get('/dashboard/service-area-stats')
}

// 获取客户满意度统计
export function getCustomerSatisfactionStats() {
  return get('/dashboard/customer-satisfaction')
}

// 获取订单状态分布
export function getOrderStatusDistribution() {
  return get('/dashboard/order-status-distribution')
}

// 获取收入趋势分析
export function getRevenueTrend(timeRange = '7d') {
  return get('/dashboard/revenue-trend', { timeRange })
}

// 获取服务完成率统计
export function getServiceCompletionRate() {
  return get('/dashboard/service-completion-rate')
}

// 获取客户地理分布
export function getCustomerGeographicDistribution() {
  return get('/dashboard/customer-geographic')
}

// 获取营业时间分析
export function getBusinessHoursAnalysis() {
  return get('/dashboard/business-hours-analysis')
}

// 获取服务质量指标
export function getServiceQualityMetrics() {
  return get('/dashboard/service-quality-metrics')
}

// 获取预警信息
export function getAlerts() {
  return get('/dashboard/alerts')
}

// 获取快捷操作数据
export function getQuickActions() {
  return get('/dashboard/quick-actions')
}

// 更新营业状态
export function updateBusinessStatus(status) {
  return request({
    url: '/dashboard/business-status',
    method: 'post',
    data: { status }
  })
}

// 标记预警已读
export function markAlertAsRead(alertId) {
  return request({
    url: `/dashboard/alerts/${alertId}/read`,
    method: 'post'
  })
}

// 获取洗护服务类型统计
export function getServiceTypeStats() {
  return get('/dashboard/service-type-stats')
}

// 获取取送件统计
export function getPickupDeliveryStats() {
  return get('/dashboard/pickup-delivery-stats')
}

// 获取保证金状态
export function getDepositStatus() {
  return get('/dashboard/deposit-status')
}

// 获取评价统计
export function getReviewStats() {
  return get('/dashboard/review-stats')
}

// 获取优惠券使用统计
export function getCouponUsageStats() {
  return get('/dashboard/coupon-usage-stats')
}

// ==================== 新增统计分析API ====================

// 获取时间段分析数据
export function getTimeAnalysisData(type = 'today') {
  return get('/dashboard/time-analysis', { type }, {
    showLoading: false,
    showError: true
  })
}

// 获取服务类型统计数据
export function getServiceStatsData(type = 'orders') {
  return get('/dashboard/service-stats', { type }, {
    showLoading: false,
    showError: true
  })
}

// 获取地区统计数据
export function getRegionStatsData(type = 'orders') {
  return get('/dashboard/region-stats', { type }, {
    showLoading: false,
    showError: true
  })
}

// 获取仪表板概览数据（新版本）
export function getDashboardOverview() {
  return get('/dashboard/overview', {}, {
    showLoading: false,
    showError: true
  })
}